import pandas as pd
import os

data = pd.read_excel("建筑物清单汇总.xlsx")
if not os.path.exists("分地市分场景\\"):
    os.makedirs("分地市分场景\\")
areas = set(data["城市名称"])
for area in areas:
    file_name = "分地市分场景\\" + area + ".xlsx"
    writer = pd.ExcelWriter(file_name)
    data2 = data[data["城市名称"] == area]
    scenes = set(list(data2["建筑场景一级标签"]))
    for scene in scenes:
        data3 = data2[data2["建筑场景一级标签"] == scene]
        data3.to_excel(writer, sheet_name=scene, index=False)
    writer.save()